﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Reflection;
using Pixysoft.Weblications.Sango.Protocol.player;
using Pixysoft.Weblications.Sango.Dao;
using Pixysoft.Weblications.Sango.Constant;
using Pixysoft.Weblications.Sango.Environment;

namespace Pixysoft.Weblications.Sango.Protocol
{
    class UsrProfileFacade
    {
        public static List<player_profile> ToProfiles(List<Entities.Usr_Profile> orms)
        {
            List<player_profile> list = new List<player_profile>();

            foreach (Entities.Usr_Profile orm in orms)
            {
                list.Add(ToProfile(orm));
            }

            return list;
        }

        internal static player_profile ToProfile(Entities.Usr_Profile profile)
        {
            player_profile body = ReflectionManager.CreatePojo<player_profile>();
            body.usercode = profile.Usercode;
            body.nickname = profile.Nickname;

            body.level = profile.Userlevel;
            body.viplevel = profile.Viplevel;

            body.cash = profile.Cashvalue;
            body.maxcash = profile.Maxcashvalue;
            body.gold = profile.Goldvalue;
            body.soul = profile.Soulvalue;
            body.fame = profile.Famevalue;

            body.resource = profile.Resourcevalue;
            body.maxresource = profile.Maxresourcevalue;
            body.soldier = profile.Soldiervalue;
            body.maxsoldier = profile.Maxsoldiervalue;
            return body;
        }

        public static player_property ToProperty(Entities.Usr_Property orm)
        {
            player_property body = ReflectionManager.CreatePojo<player_property>();

            body.fametypecode = orm.Fametitletypecode;

            body.traincount = orm.Trainingcount;
            body.buildingcount = orm.Buildingcount;

            body.repositorycount = orm.Repositorycount;
            body.usedrepositorycount = orm.Usedrepositorycount;

            body.bannercount = orm.Bannercount;

            body.hiredofficercount = orm.Hiredofficercount;
            body.officercount = orm.Officercount;

            return body;
        }

        public static player_activity ToActivity(Entities.Usr_Profile profile, Entities.Usr_Activity orm)
        {
            player_activity body = ReflectionManager.CreatePojo<player_activity>();

            body.scoutcount = orm.Scoutcount;

            body.action = orm.Freebattlecount;
            body.maxaction = 20;

            body.forcescoutcount = SysVipSettingHelper.search(profile.Viplevel).Forcescoutqty;
            body.usedforcescoutcount = orm.Forcescoutcount;

            return body;
        }
    }
}
